/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.crystalrange.enterprise.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.crystalrange.model.User;

/**
 *
 * @author tbekasiewicz
 */
public class SalesOrder implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;
    private Debtor debtor;
    private List<SalesOrderItem> salesOrderItems;
    private User createdBy;
    private Date createdDate;
    private User updatedBy;
    private Date updatedDate;
    
    public SalesOrder() {
        this.id = 0L;
        this.salesOrderItems = new ArrayList<SalesOrderItem>();
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Debtor getDebtor() {
        return this.debtor;
    }

    public void setDebtor(Debtor debtor) {
        this.debtor = debtor;
    }

    public List<SalesOrderItem> getSalesOrderItems() {
        return salesOrderItems;
    }

    public void setSalesOrderItems(List<SalesOrderItem> salesOrderItems) {
        this.salesOrderItems = salesOrderItems;
    }

    public Double getNetAmount() {
        Double netAmount = 0.00;
        for (SalesOrderItem salesOrderItem : this.salesOrderItems) {
            netAmount += salesOrderItem.getNetAmount();
        }
        return netAmount;
    }
        
    public User getCreatedBy() {
        return this.createdBy;
    }

    public void setCreatedBy(User createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedDate() {
        return this.createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public User getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(User updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedDate() {
        return this.updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }    
}
